package com.gagakuai.demo;

import com.gagakuai.demo.beanFactoryPostProccess.CompoentConfig;
import com.gagakuai.demo.condit.MainConfig1;
import com.gagakuai.demo.condit.MainConfigtion;
import com.gagakuai.demo.registrytest.AbstractService;
import com.gagakuai.demo.registrytest.ServiceContext;
import com.gagakuai.demo.testPoceesor.TestBeanDefinitionRegistryPostProcessor;

import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.List;

/*
 * @program: settement
 * @description: 测试
 * @author: houhong
 * @create: 2022-11-12 10:11
 */
public class MainTest {

    public static void main(String[] args) throws Exception {


        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(CompoentConfig.class);

       /* context.scan("com.gagakuai.demo.registrytest");
        context.refresh();*/
        // context.addBeanFactoryPostProcessor(new TestBeanDefinitionRegistryPostProcessor());
        System.out.println("===============beanFactoryPostProcessor===============");
        List<BeanFactoryPostProcessor> beanFactoryPostProcessors = context.getBeanFactoryPostProcessors();
        for (BeanFactoryPostProcessor beanFactoryPostProcessor : beanFactoryPostProcessors) {
            System.out.println(beanFactoryPostProcessor);
        }

        DefaultListableBeanFactory beanFactory = context.getDefaultListableBeanFactory();

        System.out.println("===============beanPostProcessor===============");
        List<BeanPostProcessor> beanPostProcessors = beanFactory.getBeanPostProcessors();
        for (BeanPostProcessor beanPostProcessor : beanPostProcessors) {
            System.out.println(beanPostProcessor);
        }
        /*
        String[] definitionNames = context.getBeanDefinitionNames();


        for (String definitionName : definitionNames) {
            System.out.println(String.format("%s->%s", definitionName, context.getBean(definitionName)));
        }*/


    }
}